package com.lhx.gmall.user.service.Impl;


import com.lhx.gmall.bean.UmsMember;
import com.lhx.gmall.bean.UmsMemberReceiveAddress;
import com.lhx.gmall.service.UserService;
import com.lhx.gmall.user.mapper.UmsMemberReceiveAddressMapper;
import com.lhx.gmall.user.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper userMapper;

    @Autowired
    UmsMemberReceiveAddressMapper umsMemberReceiveAddressMapper;


    @Override
    public List<UmsMember> getAllUser() {
//        List<UmsMember> umsMemberList=userMapper.selectAllUser();
        List<UmsMember> umsMemberList =userMapper.selectAllUser();
        return umsMemberList;
    }

    @Override
    public List<UmsMemberReceiveAddress> getReceiveAddressByMemberId(String memberId) {






//        UmsMemberReceiveAddress umsMemberReceiveAddress = new UmsMemberReceiveAddress();
//
//         umsMemberReceiveAddress.setMemberId(memberId);
//         List<UmsMemberReceiveAddress> umsMemberReceiveAddressList = umsMemberReceiveAddressMapper.select(umsMemberReceiveAddress);
        Example  e = new Example(UmsMemberReceiveAddress.class);
        //创建一个CreteriaandEqualTo()过滤条件
        e.createCriteria().andEqualTo("memberId",memberId);
        //批量查询
          List<UmsMemberReceiveAddress>  umsMemberReceiveAddressList  = umsMemberReceiveAddressMapper.selectByExample(e);
         return umsMemberReceiveAddressList;

    }
}
